package cn.itsource.order.controller;


import cn.itsource.basic.util.JsonResult;
import cn.itsource.order.domain.OrderAddress;
import cn.itsource.order.domain.OrderAdopt;
import cn.itsource.order.domain.ParamDo;
import cn.itsource.order.service.IOrderAdoptService;
import cn.itsource.pet.domain.Pet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@Controller
@Slf4j
@RequestMapping("adoptOrder")
public class OrderAdoptController {
    @Autowired
    private IOrderAdoptService orderAdoptService;
    @PostMapping("submitOrder")
    @ResponseBody
    public JsonResult submitOrder(@RequestBody ParamDo paramDo){
        return orderAdoptService.submitOrder(paramDo);
    }
    @PostMapping("price")
    @ResponseBody
    public JsonResult getPrice(@RequestBody ParamDo paramDo){
        Pet price = orderAdoptService.getPrice(paramDo);
        return JsonResult.createSuccess(price);
    }
    @GetMapping("salePrice/{orderSn}")
    @ResponseBody
    public JsonResult getPrice(@PathVariable String orderSn){
        OrderAdopt orderAdopt = orderAdoptService.salePrice(orderSn);
        return JsonResult.createSuccess(orderAdopt);
    }
    @GetMapping("address/{orderSn}")
    @ResponseBody
    public JsonResult address(@PathVariable String orderSn){
        OrderAddress address = orderAdoptService.address(orderSn);
        return JsonResult.createSuccess(address);
    }

}

